﻿using UnityEngine;
using System.Collections;
using System.Globalization;

/// <summary>
/// 문자열 확장 클래스.
/// </summary>
public static class StringExtensions
{
	/// <summary>
	/// 다양한 타입의 값들을 문자열로 만들기.
	/// </summary>
	/// <param name="theString"></param>
	/// <param name="vars"></param>
	/// <returns></returns>
	public static string ShowValue(this string theString, params object[] vars)
	{
		theString += " : ";

		foreach (var data in vars)
		{
			theString += " (" + data + ")";
			//theString += "  " + data;
		}

		return theString;
	}

	/// <summary>
	/// 배열을 문자열로 출력하기.
	/// </summary>
	/// <param name="theString"></param>
	/// <param name="vars"></param>
	/// <returns></returns>
	public static string ShowArray<T>(this string theString, T[] vars)
	{
		theString += " : ";

		foreach (var data in vars)
		{
			theString += " (" + data + ")";
			//theString += "  " + data;
		}

		return theString;
	}

	/// <summary>
	/// ArrayList를 문자열로 만들기.
	/// </summary>
	/// <param name="theString"></param>
	/// <param name="vars"></param>
	/// <returns></returns>
	public static string ShowArrayList(this string theString, ArrayList vars)
	{
		theString += " : ";

		foreach (var data in vars)
		{
			theString += " (" + data + ")";
			//theString += "  " + data;
		}

		return theString;
	}
}

/// <summary>
/// 문자열 관련 클래스.
/// </summary>
public static class wsText
{
	/// <summary>
	/// Type of Country.
	/// </summary>
	public enum CountryType
	{
		/// <summary>
		/// KOREA
		/// </summary>
		[StringValue("ko-KR")]
		KOREA, 
		/// <summary>
		/// AMERICA
		/// </summary>
		[StringValue("en-US")]
		AMERICA, 
		/// <summary>
		/// GERMAN
		/// </summary>
		[StringValue("de-DE")]
		GERMAN, 
		/// <summary>
		/// JAPAN
		/// </summary>
		[StringValue("ja-JP")]
		JAPAN, 
		/// <summary>
		/// FRANCE
		/// </summary>
		[StringValue("fr-FR")]
		FRANCE
	};

	/// <summary>
	/// Gets the currency format.
	/// </summary>
	/// <returns>
	/// The currency format.
	/// </returns>
	/// <param name='money'>
	/// Money.
	/// </param>
	/// /// <param name='countryType'>
	/// Culture name : "ko-KR", "en-US", "de-DE", "ja-JP", "fr-FR"
	/// </param>
	public static string GetCurrencyFormat(double money, CountryType countryType)
	{
		NumberFormatInfo NF = new CultureInfo(countryType.GetStringValue(), false).NumberFormat;
		return money.ToString("C", NF);
	}

	/// <summary>
	/// 숫자앞에 0으로 자리수 채우기.
	/// 10진수 8자리, D8
	/// 16진수 8자리, X8
	/// 예) int num = 123; num.ToString("D8");
	/// </summary>
	/// <param name="num">출력할 숫자</param>
	/// <param name="digit">출력할 자리수</param>
	/// <returns>생성된 문자열</returns>
	public static string ShowNumWithDigit(int num, int digit)
	{
		return num.ToString("D"+digit);
	}
}
